package com.ali.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;
import java.util.UUID;

public class RandomUtil {
    private static final Logger logger = LoggerFactory.getLogger("RandomUtil");

    /**
     * 获取随机数
     */
    public static int getRandom(int min, int max) {
        Random random = new Random();
        int value = random.nextInt(max);
        if (value < min) {
            return value + min;
        }
        return value;
    }

    /**
     * 获取UUID
     */
    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        logger.info("uuid：" + uuid);
        logger.info("uuid.version：" + uuid.version());
        String uuidStr = uuid.toString();
        logger.info("uuidStr：" + uuidStr);
        uuidStr = uuidStr.replace("-", "");
        return uuidStr;
    }
}